﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Wordprocessing;
using DocumentFormat.OpenXml.Packaging;
using intelliEssay.Core;
using intelliEssay.Core.DocumentStructure;
using System.Reflection;


namespace TestDrive
{
    class _testEntry
    {
        static void Main()
        {
            Task tsk = new Task();
            tsk.FilePath = @"C:\Users\llmainland\Desktop\testFiles\9_debug.docx";
            tsk.taskType = "nkuB";
            tsk.taskSetting.StandardFormatDocumentPath = @"E:\Programs\ProjectEssayCompiler\TestDrive\intelliEssay\standard format.docx";
            tsk.Initialize();
            intelliEssay.Checkers.DocumentKeyElementSequenceChecker.intelliEssayDocumentKeyElementSequenceChecker something = new intelliEssay.Checkers.DocumentKeyElementSequenceChecker.intelliEssayDocumentKeyElementSequenceChecker();
            tsk.AddAChecker(something);
            tsk.Run(TaskRunMode.Console);
        }
    }
    static class _DebugHandy
    {
        public static void Serialize(DocumentStructure ds)
        {
            StringBuilder sb = new StringBuilder();
            var fields = ds.GetType().GetFields();
            foreach (FieldInfo fi in fields)
            {
                object o = fi.GetValue(ds);
                if (o.GetType() == typeof(List<Paragraph>) && fi.Name.ToLowerInvariant() != "maindocumentbody")
                {
                    var paraList = o as List<Paragraph>;
                    sb.Append(fi.Name + Environment.NewLine);
                    foreach (Paragraph p in paraList)
                    {
                        sb.Append(p.InnerText + Environment.NewLine);
                    }
                    continue;
                }
                var paragraph = o as Paragraph;
                if (paragraph != null)
                {
                    sb.Append(paragraph.InnerText + Environment.NewLine);
                }
            }
            System.IO.StreamWriter sw = new System.IO.StreamWriter(System.IO.File.Create("g:\\testdrive\\result.txt"));
            sw.WriteLine(sb.ToString());
            sw.Dispose();
        }
    }
}
